Skip to content

fix: tighten Sentry idiom and typing micro-issues#96

Merged
lesnik512 merged 1 commit into
mainfrom
fix/low-1-2-sentry-micro
Jun 1, 2026
Merged

fix: tighten Sentry idiom and typing micro-issues#96
lesnik512 merged 1 commit into
mainfrom
fix/low-1-2-sentry-micro

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Two micro-fixes in sentry_instrument.py:

  • LOW-1: wrap_before_send_callbacks used if not callback: to skip None entries in *callbacks. Callables are always truthy unless they define __bool__, so the truthiness check is semantically wrong (happens to work for normal callables, but obscures the intent). Use if callback is None: to match the intent — also the PEP 8 canonical form for singleton checks.
  • LOW-2: SentryConfig.sentry_before_send was annotated Callable[[Any, Any], Any | None] | None. The inner Any | None collapses to Any, so the annotation reduces to Callable[..., Any] | None — the union adds nothing. Use the proper sentry_types.EventProcessor | None (string-quoted; the type lives under TYPE_CHECKING).

No behavior change. No new tests — existing Sentry tests cover both paths.

Closes LOW-1 and LOW-2 from an internal audit.

Test plan

  • just test -- tests/instruments/test_sentry_instrument.py -v — pass.
  • just test — 89/89.
  • just lint — clean.

🤖 Generated with Claude Code

LOW-1: wrap_before_send_callbacks used `if not callback:` to skip None
entries in *callbacks. Callables are always truthy unless they define
__bool__, so the truthiness check is semantically wrong even if it
happens to work. Use `if callback is None:` to match the intent.

LOW-2: SentryConfig.sentry_before_send was annotated
`Callable[[Any, Any], Any | None] | None`. The inner `Any | None`
collapses to `Any`, so the annotation reduces to
`Callable[..., Any] | None` — the union adds nothing. Use the proper
`sentry_types.EventProcessor | None` instead (already imported under
TYPE_CHECKING in the same file).

No behavior change.

Closes LOW-1 and LOW-2 from the audit.
@lesnik512 lesnik512 self-assigned this Jun 1, 2026
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
lite_bootstrap/instruments/sentry_instrument.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lesnik512 lesnik512 merged commit 18656eb into main Jun 1, 2026
8 checks passed
@lesnik512 lesnik512 deleted the fix/low-1-2-sentry-micro branch June 1, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant